then

infix inline fun <T> Any?.then(next: T): T(source)

Purely cosmetic function for creating cursed one-liners. Disregards the receiver and returns the next value.

Samples

import dev.kikugie.commons.then
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   fun incrementChecked(value: Int) = require(value < Int.MAX_VALUE) then value + 1

assertEquals(2, incrementChecked(1))
assertFailsWith<IllegalArgumentException> { incrementChecked(Int.MAX_VALUE) } 
   //sampleEnd
}